//
//  SISSPriceMapSearchViewCell.m
//  SISSAPP
//
//  Created by 袁应荣 on 2018/12/3.
//  Copyright © 2018年 优房网. All rights reserved.
//

#import "SISSPriceMapSearchViewCell.h"

@interface SISSPriceMapSearchViewCell ()

/// 楼盘名称
@property (weak, nonatomic) UILabel *buildNameLabel;
/// 售
@property (weak, nonatomic) UILabel *sellLabel;
/// 租
@property (weak, nonatomic) UILabel *rentLabel;
/// 区-板块
@property (weak, nonatomic) UILabel *townAndBlockLabel;
/// 底部线条
@property (weak, nonatomic) UIView *bottomLine;

@end
@implementation SISSPriceMapSearchViewCell

- (void)setSearchPnameModel:(SISSMapSearchPnameModel *)searchPnameModel {
    _searchPnameModel = searchPnameModel;
    
    self.buildNameLabel.text = searchPnameModel.buildName;
    
    NSString *sellStr = [NSString stringWithFormat:@"【售价】- %@- %@元/㎡",searchPnameModel.sellMaxBtype,searchPnameModel.sellPrice];
    NSMutableAttributedString *sellAttri = [[NSMutableAttributedString alloc] initWithString:sellStr];
    NSRange sellRange = [sellStr rangeOfString:searchPnameModel.sellPrice];
    [sellAttri addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:sellRange];
    self.sellLabel.attributedText = sellAttri;
    
    NSString *rentStr = [NSString stringWithFormat:@"【租金】- %@元/月/㎡",searchPnameModel.rentPrice];
    NSMutableAttributedString *rentAttri = [[NSMutableAttributedString alloc] initWithString:rentStr];
    NSRange rentRange = [rentStr rangeOfString:searchPnameModel.rentPrice];
    [rentAttri addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:rentRange];
    self.rentLabel.attributedText = rentAttri;
    
    self.townAndBlockLabel.text = searchPnameModel.areablock;
}

#pragma mark - UI
- (void)initUI {
    [super initUI];
    
    UILabel *buildNameLabel = [UILabel yyr_labelWithText:@"" fontSize:13 textColor:MAIN_TEXT_COLOR];
    [self.contentView addSubview:buildNameLabel];
    self.buildNameLabel = buildNameLabel;
    
    UILabel *sellLabel = [UILabel yyr_labelWithText:@"" fontSize:13 textColor:MAIN_TEXT_COLOR];
    [self.contentView addSubview:sellLabel];
    self.sellLabel = sellLabel;
    
    UILabel *rentLabel = [UILabel yyr_labelWithText:@"" fontSize:13 textColor:MAIN_TEXT_COLOR];
    [self.contentView addSubview:rentLabel];
    self.rentLabel = rentLabel;
    
    UILabel *townAndBlockLabel = [UILabel yyr_labelWithText:@"" fontSize:13 textColor:SECONDARY_TEXT_COLOR];
    [self.contentView addSubview:townAndBlockLabel];
    self.townAndBlockLabel = townAndBlockLabel;
    
    UIView *bottomLine = [[UIView alloc] init];
    bottomLine.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.contentView addSubview:bottomLine];
    self.bottomLine = bottomLine;

}

#pragma mark - 约束
- (void)initConstraint {
    [super initConstraint];
    
    WeakSelf
    [self.buildNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView).offset(2 * globelMargin);
        make.top.equalTo(weakSelf.contentView).offset(globelMargin);
    }];
    
    [self.sellLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.buildNameLabel).offset(-0.5 * globelMargin);
        make.top.equalTo(weakSelf.buildNameLabel.mas_bottom).offset(globelMargin);
    }];
    
    [self.rentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.sellLabel.mas_right).offset(2 * globelMargin);
        make.top.equalTo(weakSelf.sellLabel);
    }];
    
    [self.townAndBlockLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.buildNameLabel);
        make.top.equalTo(weakSelf.sellLabel.mas_bottom).offset(globelMargin);
    }];
    
    [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.townAndBlockLabel.mas_bottom).offset(globelMargin);
        make.left.right.bottom.equalTo(weakSelf.contentView);
    }];
}

@end
